<?php
$title="Recommend List";
$css="others.css";
include_once 'common/AdminTop.php';
include_once 'authentic.php';
include_once '../Class/DB.php';
$db=new DB();
$recommends=$db->get_recommend();
?>
<div id="userlist" align="center">
<table id="userlistTable" border="1" style="margin-top:20px;font-size: 12pt;">
	<tbody>
		<tr style="color:white;">
			<th width="32px"><p>No</p></th>
			<th width="150px"><p>Recommended Product</p></th>
			<th width="72px"><p>Type</p></th>
			<th width="140px"><p>Banner</p></th>
			<th width="30px"></th>
		</tr>
		<?php 
		$i=0;
		while(isset($recommends[$i]))
		{
			//echo "ss";
			//exit();
			$theProduct=$db->get_pid_product($recommends[$i]["pid"]);
			if($theProduct[0]==null)
			{
				$i++;
			continue;
			}
			$theType=$db->get_tid_types($theProduct[0]["type"]);
			if($theType[0]==null)
			{
				$i++;
			continue;
			}
			
		?>
		<tr style="color:white;">
			<td align="center"><p><?php echo $i+1;?></p></td>
			<td width="" align="center"><p><a href="modifyRecommend.php?id=<?php echo $recommends[$i]["rid"];?>"><?php echo $theProduct[0]["p_name"];?></a></p></td>
			<td align="center"><p><?php echo $theType[0]["name"];?></p></td>
			<td align="center"><img alt="banner view" align="middle" src="<?php if(file_exists("../Image/Hot/".$recommends[$i]["rid"].".jpg")){echo "../Image/Hot/".$recommends[$i]["rid"].".jpg";}else{echo "../Image/Hot/no_pic.png";}?>" style="width:130px;height:30px" /></td>
		    <td width="" align="center"><p><a href="recommendDelete.php?id=<?php echo $recommends[$i]["rid"];?>">
				<img alt="x" src="../image/delete.png" width="14">
			</a></p></td>
		</tr>
		<?php 
		$i++;
		}
		?>
	</tbody>
</table>
<br>
<input type="button" name="addBtn" value="Add Recommend" onclick="window.location.href='AddRecommend.php';"/>
</div>
<?php 
include_once 'common/AdminTail.php';
?>